HowtoBecomeaProgrammer
About UsContact UsThe datetime module, as the name implies, gives access to a wide range of time related functions. Due to the sheer amount of methods and attributes in this module, I can not cover them all, however there is a complete list of all available methods and attributes here.
One of the most useful methods in this method is the .now() method, which will tell us the current time and date:
import datetime
print(datetime.datetime.now())
So we first import the module we want as always, which in our case is the datetime module. Then we use the print() function to output the datetime module's class datetime, which has a method called now(). At the time of creating this lesson, this method outputted 2019-01-07 16:21:38.399280, the current date, time to the nearest nanosecond, very nice precision.
Another useful module from a different class